package Hot100.Greedy_algorithm;

import java.util.Map;

public class canJump {
    public static void main(String[] args) {
        int nums [] = {3,2,1,0,4};
        System.out.println(new canJump().canJump(nums));
    }
    public boolean canJump(int[] nums) {
        if(nums.length == 1){
            return true;
        }
        int cover = 0;
        for (int i = 0; i <= cover; i++) {
            cover = Math.max(cover,i + nums[i]);
            if(cover >= nums.length - 1){
                return true;
            }
        }
        return false;
    }
}
